Introduce types, e.g. DivDiffData, to get around complicated broadcast machinery
#142
+432
−29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@dlfivefifty Is this roughly what you had in mind for trying to get around some of the broadcast machinery? I'm simply caching the broadcast results in a
CachedBroadcastVectorwithcache_filldata!implemented asIt's currently only implemented in
divdiffto get an idea of what it looks like:which is a bit annoying as it requires a bunch of individual
CBVcalls. I did initially start with aCachedFusedBroadcastVectorbut it's somewhat unreadable as I need to manually build theTupleof functions and vectors. I also tried specific structs for each type of operation, e.g.RangeTimesAccumulate, but getting this type of struct correct seems nicer.There's an issue with this implementation though that I'm not sure I understand. It keeps trying to indefinitely resize the vector in some cases. For example, putting a
@show inds, K.datasizeinsideLazyArrays.cache_filldata!(K::CachedBroadcastVector{T, F, A, B}, inds) where {T, F, A, B}and differentiating a weighted basis,Any idea what's going on with this implementation that it keeps wanting to resize? I thought
_vec_resizedata!(B::AbstractVector, n)should get around this automatically. Note that the indexing does work sometimes though, e.g.works and uses
CachedBroadcastVector.